package cn.doubly.Bean;

import com.alibaba.fastjson.JSON;

public class Message {
    public static final String ENTER = "ENTER";
    public static final String SPEAK = "SPEAK";
    public static final String QUIT = "QUIT";

    private String type;//消息类型
    private String msg;//消息内容
    private String fromUser;//发送消息的人
    private String toUser;//指定发送的人
    private int onlineCount;//在线的人

    public Message(String type, String msg, String fromUser, String toUser, int onlineCount) {
        this.type = type;
        this.msg = msg;
        this.fromUser = fromUser;
        this.toUser = toUser;
        this.onlineCount = onlineCount;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getFromUser() {
        return fromUser;
    }

    public void setFromUser(String fromUser) {
        this.fromUser = fromUser;
    }

    public String getToUser() {
        return toUser;
    }

    public void setToUser(String toUser) {
        this.toUser = toUser;
    }

    public int getOnlineCount() {
        return onlineCount;
    }

    public void setOnlineCount(int onlineCount) {
        this.onlineCount = onlineCount;
    }

    public static String jsonStr(String type, String msg, String fromUser, String toUser,int onlineTotal){
        return  JSON.toJSONString(new Message(type,msg,fromUser,toUser,onlineTotal));
    }
}
